#pragma once

#include <stdio.h>
#include <XnCppWrapper.h>
#include "Skeleton.h"



class KinectReader
{
public:
	
	// public constants
	static const int MAX_USERS = 15;
	static const int MAX_IGNORED_READINGS = 100;
	

	// public instance variables
	static KinectReader * instance;


	// public methods
	static KinectReader * getInstance() {
		if(!instance) {
			instance = new KinectReader(false);
		}
		return instance;
	}

	xn::UserGenerator * getUserGenerator() {
		return this->userGenerator;
	}

	void updateSkeletonData();

	Skeleton * getSkeletons() {
		return this->skeletons;
	}

private: 

	// private constructors

	KinectReader(bool mirrorMode);
	~KinectReader(void);


	// private instance variables
	xn::Context * context;
	xn::DepthGenerator * depth;
	xn::UserGenerator * userGenerator;
	bool mirrorMode;
	XnChar g_strPose[20];
	Skeleton skeletons[KinectReader::MAX_USERS];
	XnMapOutputMode * mapMode;

	float jointCoords[4];

	//Multipliers for coordinate system. 
	double mult_x;
	double mult_y;
	double mult_z;

	//Offsets for coordinate system. 
	double off_x;
	double off_y;
	double off_z;


	// private methods
	void checkRetVal(XnStatus nRetVal);
	int jointPos(XnUserID player, XnSkeletonJoint eJoint);
	void initSkeletons();

};
